function [img, count, avail] = f3e_simple(img, msg)
    % F3E_SIMPLE  Embed message using F3.
    
    bin = arrayToBinary(msg);
    data_size = size(bin,2);

    ROWS = size(img,1)/8;
    r = int16(im2vec(img, [8 8])');
    [M,N] = size(r);

    avail = countNonZero(r);
    fprintf(1, 'max_avail = %db\n',avail);

    % hide every bit
    count = 1;
    p = 0;

    for i=1:M
        if count > data_size
            break
        end
        for j=2:N
            if count > data_size
                break
            end
            p = p + 1;
            v = r(i, j);
            if v == 0
                continue
            end
            if mod(v,2) == mod(bin(1, count), 2)
                count = count + 1;
            else
                if v > 0
                    v = v - 1;
                else
                    v = v + 1;
                end
                r(i,j) = v;
                if v ~= 0
                    count = count + 1;
                end
            end
        end
    end
    
    count = count - 1;
    img = vec2im(double(r)', [0 0], [8 8], ROWS);

    % output
    if count < data_size
        len = floor((count-16)/8);
        fprintf(1,'part of message hidden in whole image. %3.3f bpp, %3.3f bpc\n', count/M/N, count/avail);
        fprintf(1,' msg = %dB (%db), %3.2f%%\n',len, count,100*count/data_size);
    else
        fprintf(1,'whole message hidden in part of image. %3.3f bpp, %3.3f bpc\n', count/M/N, count/avail);
        fprintf(1,' coef = %db, %3.2f%%\n',p,100*p/M/N);
    end
end
